#!/usr/bin/bash
hc() {
    herbstclient "$@"
}

# reset
hc keyunbind --all
hc mouseunbind

# Theme settings
hc set frame_gap 8
hc set window_gap 2
hc set frame_bg_transparent 1
hc set frame_transparent_width 0
hc set frame_active_opacity 100
hc set frame_normal_opacity 0
hc set frame_border_width 1
hc set frame_border_active_color "#$BACKGROUND"
hc set frame_border_normal_color "#$FOREGROUND"
hc set window_border_active_color "#$BACKGROUND"
hc set window_border_normal_color "#$CURSOR_COLOR"
hc set window_border_width 1
hc set smart_frame_surroundings 1
hc set smart_window_surroundings 1

# Behavior
hc set focus_crosses_monitor_boundaries 1
hc set auto_detect_monitors 1

# Numeric tags
for TAG in 0 1 2 3 4 5 6 7 8 9
do
    hc add "$TAG"
    hc keybind "Super+$TAG" use "$TAG"
    hc keybind "Super+Shift+$TAG" move $TAG
done

hc use 1
hc merge_tag default 0

# Mouse commands
hc mousebind Super-B1 move
hc mousebind Super-B3 resize

key() {
    hc keybind "$@"
}

# Keyboard commands
key Super+e spawn emenu
key Super+Shift+r reload
key Super+q quit
key Super+space spawn dmenu_run
key Super+Return spawn urxvt
key XF86MonBrightnessUp spawn xbacklight -inc 5
key XF86MonBrightnessDown spawn xbacklight -dec 5
key XF86AudioRaiseVolume spawn pactl set-sink-volume 0 '+10%'
key XF86AudioLowerVolume spawn pactl set-sink-volume 0 '-10%'
key XF86AudioMute spawn pactl set-sink-mute 0 toggle

# Window movement
key Super+n split auto
key Super+u split top
key Super+i split right
key Super+r remove
key Super+c close
key Super+o rotate
key Super+Control+h shift left
key Super+Control+l shift right
key Super+Control+j shift down
key Super+Control+k shift up
key Super+h focus left
key Super+l focus right
key Super+j focus down
key Super+k focus up
key Super+Shift+h resize left +0.05
key Super+Shift+l resize right +0.05
key Super+Shift+j resize down +0.05
key Super+Shift+k resize up +0.05
key Super+p pseudotile toggle
key Super+f floating toggle
